package com.fzn3.day07;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import java.util.Arrays;

/**
 * @author fzn
 * 描述：
 * @program DataStructure
 * @create 2023/3/13 15:57
 **/
public class TestLinkedListStack {

    @Test
    public void push() {
        LinkedListStack<Object> stack = new LinkedListStack<>(3);
        stack.push(1);
        stack.push(2);
        stack.push(3);

        Assertions.assertFalse(stack.push(4));

        Assertions.assertIterableEquals(Arrays.asList(3, 2, 1), stack);
    }

    @Test
    public void pop() {
        LinkedListStack<Object> stack = new LinkedListStack<>(3);
        stack.push(1);
        stack.push(2);
        stack.push(3);

        Assertions.assertEquals(3, stack.pop());
        Assertions.assertEquals(2, stack.pop());
        Assertions.assertEquals(1, stack.pop());
        Assertions.assertNull(stack.pop());
    }
}
